#include "BoardView.h"

#include <boost/bind.hpp>
#include "../../models/network/CardViewModel.h"
#include "../../../domain/configuration/NetworkConfiguration.h"

using namespace Views::Remote;

BoardView::BoardView(Domain::Network::GameClient* client)
	: client(client)
{
}

void BoardView::askForPlayerNewPosition(Players::Player* player, Cards::RoomsCards rooms_cards)
{
#ifdef _DEBUG
	std::clog << __FUNCTION__ << " Czekam na pokoj" << std::endl;
#endif
	this->rooms_cards = rooms_cards;
	client->doOnReceiveData(Domain::Configuration::Network::BOARD_ROOM_PICK, boost::bind(&BoardView::onRoomPick, this, _1));
}

void BoardView::onRoomPick(sf::Packet Packet)
{
	Cards::CardsCollection cards(Cards::PlayersCards(), Cards::WeaponsCards(), rooms_cards);
	Views::Models::Network::CardViewModel cvm(cards);
	Packet >> cvm;
	playerRoomChangeEvent(dynamic_cast<Cards::RoomCard*>(cvm.card)->room);
}

